// Maciej Chałapuk (maciej@chalapuk.pl)
// vim: ts=2 sw=2 expandtab
#include "stochastic_number.hpp"
#include <iostream>
#include <random>
#include <bitset>

const size_t iters = 1000;
typedef experiment::stochastic8192_t testtype;
//typedef experiment::stochastic_number<8192, std::bitset<8192>> testtype;

int main(int argc, char* argv[]) {
  std::random_device rd;
  std::mt19937 gen(rd());

  long double errSquare = 0;
  for (size_t i = 0; i < iters; ++i) {
    long double a = std::generate_canonical<long double, 10>(gen);
    long double b = std::generate_canonical<long double, 10>(gen);
    long double result = testtype(a) * testtype(b);
    long double err = result - (a * b);
    std::cout << a << " * " << b << " = " << result
      << "; err = " << err << std::endl;
    errSquare += std::pow(err, 2);
  }

  std::cout << "avg err^2 = " << (errSquare/iters) << std::endl;
}

